from myapp.exts import db


class Userinfo(db.Model):
    __tablename__ = 'userinfo'
    userid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(255))
    password = db.Column(db.String(255))
    email = db.Column(db.String(255))
    job = db.Column(db.String(255))
    birthday = db.Column(db.String(255))
    phoneNum = db.Column(db.String(255))

    def __init__(self, username=None, password=None, email=None, job=None, birthday=None, phoneNum=None):
        self.username = username
        self.password = password
        self.email = email
        self.job = job
        self.birthday = birthday
        self.phoneNum = phoneNum

    def __repr__(self):
        return f'<UserInfo:{self.userid} : {self.username} : {self.password} : {self.email} : {self.job} : {self.birthday}:{self.phoneNum}>'

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}
